<template>
  <div class="my">
    <div class="bg">
      <img src="../assets/images/setting_head_bg.png" alt="" />
    </div>
    <router-link tag="div" to="/login" class="info">
      <div class="avatar">
        <img src="../assets/images/ic_lanucher_bobi.png" alt="" />
        <p class="nickname" v-if="username">{{ username }}</p>
        <p class="nickname" v-else>点击登录</p>
      </div>
      <span class="iconfont icon-youjiantou"></span>
    </router-link>
    <div class="list">
      <div class="item">
        <div class="left">
          <div class="img">
            <img src="../assets/images/icon_mine_info.png" alt="" />
          </div>
          <p>我的信息</p>
        </div>
        <span class="iconfont icon-youjiantou"></span>
      </div>
      <div class="item">
        <div class="left">
          <div class="img">
            <img src="../assets/images/icon_mine_history.png" alt="" />
          </div>
          <p>每日签到</p>
        </div>
        <span class="iconfont icon-youjiantou"></span>
      </div>
      <div class="item">
        <div class="left">
          <div class="img">
            <img src="../assets/images/icon_mine_kid.png" alt="" />
          </div>
          <p>青少年模式</p>
        </div>
        <span class="iconfont icon-youjiantou"></span>
      </div>
      <div class="item">
        <div class="left">
          <div class="img">
            <img src="../assets/images/icon_mine_setting.png" alt="" />
          </div>
          <p @click="quit">退出登录</p>
        </div>
        <span class="iconfont icon-youjiantou"></span>
      </div>
      <div class="item">
        <div class="left">
          <div class="img">
            <img src="../assets/images/icon_mine_advice.png" alt="" />
          </div>
          <p>意见反馈</p>
        </div>
        <span class="iconfont icon-youjiantou"></span>
      </div>
    </div>
    <FootCom />
  </div>
</template>

<script>
import FootCom from "../components/FootCom.vue";

export default {
  data() {
    return {
      username: localStorage.getItem("userId") || "",
    };
  },
  //清除缓存，退出登录
  methods: {
    quit() {
      window.localStorage.removeItem("token");
      window.localStorage.removeItem("userId");
      this.$toast("退出成功");
      this.username=""
    },
  },

  components: {
    FootCom,
  },
};
</script>

<style lang="scss" scoped>
.my {
  background-color: #f4f4f4;
  height: 100vh;
  position: relative;
  .bg {
    width: 100%;
    height: 180px;
    border-bottom-right-radius: 180px 15px;
    border-bottom-left-radius: 180px 15px;
    overflow: hidden;
    img {
      width: 100%;
      // height: 100%;
      position: relative;
      top: -60px;
      left: 0;
    }
  }
  .info {
    padding: 0px 40px;
    height: 60px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 45px;
    left: 0px;
    .avatar {
      display: flex;
      align-items: center;
      img {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        margin-right: 20px;
      }
      p {
        font-size: 16px;
        color: #fff;
      }
    }
    span {
      font-size: 16px;
      color: #fff;
      font-weight: bold;
    }
  }
  .list {
    padding: 0px 15px;
    position: relative;
    top: -20px;
    .item {
      height: 45px;
      line-height: 45px;
      padding: 0px 12px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-radius: 7px;
      background-color: #fff;
      margin-bottom: 30px;
      .left {
        display: flex;
        align-items: center;
        .img {
          width: 24px;
          height: 24px;
          margin-right: 10px;
          img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }
        p {
          font-size: 14px;
          color: #333;
          font-weight: bold;
        }
      }

      span {
        font-size: 16px;
        color: #666;
        font-weight: bold;
      }
    }
  }
}
</style>